package com.cet.java8;

/**
 * @program: cet-practice
 * @description:
 * @author: 陈恩涛
 * @create: 2022-12-07 13:02
 **/
public class VUtils {

    public static ThrowExceptionFunciton isTure(boolean b) {
        return  errorMessage -> {
            if (b) {
                throw new RuntimeException(errorMessage);
            }
        };
    }

    public static BranchHandler isTrueOrFalse(boolean b) {
        return (trueHandler, falseHandler) -> {
            if (b) {
                trueHandler.run();
            } else {
                falseHandler.run();
            }
        };
    }

    public static PresentOrElseHandler<String> isBlankOrNot(String str) {
        return (consumer, runnable) -> {
            if (str == null || str.length() == 0) {
                runnable.run();
            } else {
                consumer.accept(str);
            }
        };
    }
}
